﻿// See https://aka.ms/new-console-template for more information
using Dijiang;
using Dijiang.Values;


CmdEnv global = new CmdEnv();

BuiltinFunctions.Load(global);
FFIFunctions.Load(global);

bool running = true;

global.Put("quit", new DBuiltin((CmdEnv env, DSequence args) => { running = false; return new DList(); }));
global.Put("println", new DBuiltin((CmdEnv env, DSequence args) =>
{
    Console.WriteLine(args.Pop());

    return new DList();
}));

while (running)
{

    Console.Write("djsh>");
    var cmd = Console.ReadLine();

    if (cmd == null) continue;

    var expr = CmdParser.Parse(cmd);
    //if (expr.GetValueType() == CmdTest.ValueType.Expression && ((ExprVal)expr).Count == 0) continue;
    Console.WriteLine("ret=> " + expr.Eval(global));
}